//including standard libraries
#include <stdio.h>
#include <stdlib.h>
//including the japi functions
#include "japi.h"
//including the specific functions
#include "functions.h"

//main function
int main()
{
    //declaring variables
    int main_frame,obj,display_label;
    int file,load,menubar,quit;
    int *text_file_pointer;
    char text_file[50],*file_check;

    //to analyize the program
    j_setdebug(2);

    //if the japi application doesn't load
    if(j_start()<0)
        printf("can't connect to server\n"),exit(0);

    //creating the window frame and giving it a name
    main_frame = j_frame("Speech Recognition System");
    //creating a menu bar within the frame
    menubar = j_menubar (main_frame);
    //creating the menu drop down from the menu bar
    file = j_menu(menubar,"File");
    //creating the open file option from the file menu
    load = j_menuitem(file,"Open");
    //creating the quit option from the file menu
    quit = j_menuitem(file,"Quit");

    //dividing frame to 2 spaces
    j_setgridlayout(main_frame,2,1);

    //creating the label within the frame
    display_label = j_label(main_frame,"The Existentialists Speech Recognition System");

    //auto sizing the window
    j_pack(main_frame);
    //displaying the frame
    j_show(main_frame);

    //infinite loop
    while(1)
    {
        //for the CPU to keep checking whether anything has been actioned
        obj =  j_nextaction();
        //if the load file option was selected
        if(obj==load)
        {
            //to open a file and save it within a variable
            file_check = j_filedialog(main_frame,"Open File","",text_file);
            //checking file opened
            if(file_check!=text_file)
            {
                printf("Could not open file\n");
                exit (-1);
            }
            //function call
            //text_file_pointer=load_file_function(text_file);
        }
        //to exit the window by either the frame or the quit button
        else if((obj==quit) || (obj == main_frame))
            break;

    }
    //quiting the japi application
    j_quit();

    return 0;
}